/*
 * ls.c
 *
 *  Created on: Sep 4, 2013
 *      Author: Justin Hamric
 */

/*
	This function prints out the name and size (in bytes) of all files
    found in the current directory.
*/
 int ls(){

	char name_buf[20]; //can return a file name of length up to 20
	int buf_size = 40;
	long file_size_p; // size of returned file in bytes
	//int end_of_file = 1;
	//int holder = 1;

	//printf("In LS.\n");

	sys_open_dir("\0");
	/*
	holder = sys_get_entry(name_buf, buf_size, &file_size_p);
	printf("holder is %d at the start.\n", holder);
	*/
	while(sys_get_entry(name_buf, buf_size, &file_size_p) != -113){
		printf("%s of size %ld bytes.\n", name_buf, file_size_p);
	}

	sys_close_dir();
	/*
	while(end_of_file){
		holder = sys_get_entry(name_buf, buf_size, &file_size_p);
		if(holder == -113){
			printf("Nothing remaining in directory.\n");
			sys_close_dir();
			end_of_file = 0;
		}
		else{
			printf("%s of size %ld bytes.\n", name_buf, file_size_p);
		}
	}
	*/


	return 0;


 }




